#encoding=utf8
import urllib
import socket
import requests
from pprint import pp
socket.setdefaulttimeout(3)

proxy_ips = []

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0',
    'cookie':'__jda=122270672.16062072967971011004577.1606207297.1619544211.1619582467.31; shshshfp=723f4914e66add5236825bef4f1abd55; shshshfpa=99287815-8bf7-7648-8055-5004dcab97de-1614853083; shshshfpb=f0KBc%20PZTpO%203e9MTziuavw%3D%3D; qrsc=3; __jdv=76161171|baidu|-|organic|not set|1619195975771; PCSYCityID=CN_430000_430100_430103; TrackID=1Dt43OIz2OXKrV1ElbmF7rm48yONduvUPbp8ap-zsMQJPWrH9LXZbEGPlre2jrLGgu7uXErO1dhGX3Yjqz0YnORM-WqDi56YSkA7haT3U-B6-hz6UKczbH73Q6fiG7VBl; pinId=YMZoeXBNvKgoa3Z7zHp0p7V9-x-f3wj7; pin=jd_7551a6ebe0b16; unick=jd_7551a6ebe0b16; _tp=33QCYO9WWug7OIp5VZvueuPTU8349VfwTCZvHs7QzGs%3D; _pst=jd_7551a6ebe0b16; user-key=aace645f-0675-4b09-a4b4-960f54a335bf; __jdc=122270672; ipLoc-djd=18-1482-48939-0; rkv=1.0; areaId=18; __jdb=122270672.9.16062072967971011004577|31.1619582467; shshshsID=d4c83b3e4c6d49e6f553bde25c0f9f4c_5_1619582496879; wlfstk_smdl=tzahzdh29yyn3wzsic8btexh32mdba54; mt_xid=V2_52007VwMVU1pbU1wcQR5aDWEDE1JdWVNfG08fbARmAhoCX1oBRh8bH1UZYgARB0FQBw4XVR9fAjVQG1cKWVcKHXkaXQZnHxNXQVtbSx9KEl0FbAAbYl1oUmodTxpZDW4FFFdbaFdZGUo%3D'
}

apiUrl = 'http://ip.memories1999.com/api.php?dh=1290551019699154977&sl=10&dk=3128&xl=国内'
text = requests.get(url=apiUrl,headers=headers).text
proxyst = text.split('\r\n')[:-1]
proxys = []
pp(proxyst)
for item in proxyst:
    proxy_host = "https://"+"220.175.145.17:12000"
    proxy_temp = {"https":proxy_host}
    proxys.append(proxy_temp)
pp(proxys)

url = 'https://club.jd.com/comment/productPageComments.action?callback=fetchJSON_comment98&productId=1462103121&score=0&sortType=5&page=0&pageSize=-1'
for item in proxys:
    try:
        res = requests.get(url=url,proxies=item,headers=headers,timeout=3).text
        # res = urllib.urlopen(url,proxies=proxy_temp).read()
        print(res)
        proxy_ips.append(item)
    except Exception as e:
        print(e)
pp(proxy_ips)
